package com.itany.corejava.code07_面向对象;

/**
 * @author: 石小俊
 * @date: 2023年03月07日 10:40
 * @version: 1.0
 */
public class Test05_方法的重载 {

    public static void main(String[] args) {
        Calculator calculator = new Calculator();
        // 1、2叫做实参,实际参数
        int sum = calculator.sum(1, 2);
        double sum2 = calculator.sum(3.14, 1);
        double sum3 = calculator.sum(3.14, 5.12);
        String sum4 = calculator.sum("admin", "alice");
        int sum5 = calculator.sum(1,2,3);
        System.out.println(sum);
        System.out.println(sum2);
        System.out.println(sum3);
        System.out.println(sum4);
        System.out.println(sum5);
    }


}

class Calculator {
    // i、j叫做形参,形式参数
    public int sum(int i, int j) {
        return i + j;
    }

    public double sum(double i, int j) {
        return i + j;
    }

    public double sum(double i, double j) {
        return i + j;
    }

    public String sum(String s1, String s2) {
        return s1 + s2;
    }

    public int sum(int i, int j, int k) {
        return i + j + k;
    }
}
